<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="ko">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>게시판 상세</title>
	<script src="../js/jquery.js" type="text/javascript"></script>
	<script src="../js/validator.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(function() {
			$("#deleteBtn").click(function(){
				if(!checkAuth()) return false;
				if (confirm("정말로 삭제하시겠습니까?"))
	       		{
					$('[name=mode]').val("delete");
	       		}
				else
				{
					return false;
				}    		
			});
			
		});
		
		//img 사이지 조정
		$(window).load(function() {
			$('#view_contents').find('img').each(function(index, item) {
				
				var temp = item.width; 
		    	
				if(temp > 451)
			    {
			    	$(this).attr("width", "625px");
			    }  
			});
		});
		
		//파일 삭제
		function deleteFileBtn(bbs_id, article_id, file_id)
		{
			if(!checkAuth()) return false;
			if (confirm("정말로 삭제하시겠습니까?"))
	      	{
				location.href="../bbs/" + bbs_id + "_file_delete.do?type=view&article_id=" + article_id+ "&file_id=" + file_id;
				return true;
			}    		
		}
	</script>
</head>

<body>
	<!-- 본문 영역 -->
	<div id="contents">
		<!-- 제목 및 Location 영역 -->
		<div id="location">
			<h3 id="contentTitle"></h3>
			<div id="locationPath"></div>
		</div>
		<script type="text/javascript">
		// 현재 메뉴 경로를 설정한다.
		var pagePath = licationPth.split("_");
		var pathStr = "홈";
		for( var i=0; i < pagePath.length; i++ )
		{
			if (i+1 >= pagePath.length)
				pathStr += " &gt; <strong>" + pagePath[i] + "</strong>";
			else
				pathStr += " &gt; " + pagePath[i]
		}
		document.getElementById("contentTitle").innerHTML = pagePath[ pagePath.length - 1 ];
		document.getElementById("locationPath").innerHTML = pathStr;
		</script>
		<!-- 본문 내용 -->
		<div id="content">
			<form name="writeFrm" method="post" action="../bbs/${ bbsMap.BBS_ID }_proc.do" onsubmit="return reg(this);" enctype="multipart/form-data">
			<input type="hidden" name="mode" value="edit" />
			<input type="hidden" name="bbs_id" id="bbs_id" value="${ bbsMap.BBS_ID }" />
			<input type="hidden" name="bbs_file_count" id="bbs_file_count" value="${ bbsMap.BBS_FILE_COUNT}"/>
			<input type="hidden" name="file_count" id="file_count" value="${ viewMap.FILE_COUNT}"/>
			<input type="hidden" name="article_id" id="article_id" value="${ viewMap.ARTICLE_ID }" />
			<input type="hidden" name="article_editor" id="article_editor" value="${ adminInfo.admin_name }" />
			<input type="hidden" name="article_editor_id" id="article_editor_id" value="${ adminInfo.admin_id }" />
			<input type="hidden" name="article_content" id="article_content" />
			<input type="hidden" name="article_reg_sort" id="article_reg_sort" value="a" />
			<div class="ar"><span class="button btnProc01"></span>
			<c:if test="${ bbsMap.BBS_REPLY_YN eq 'Y' }" >
				<span class="button btnProc01"><a href="../bbs/${ bbsMap.BBS_ID }_follow.do?article_id=${viewMap.ARTICLE_ID}" id="replyBtn">답변</a></span>
			</c:if>
				<span class="button btnProc01"><input type="submit" id="deleteBtn" value="삭제" /></span>
				<span class="button btnProc01"><a href="#" onclick="checkAuth('../bbs/${ bbsMap.BBS_ID }_edit.do?article_id=${viewMap.ARTICLE_ID}');" id="btnModify">수정</a></span>
				<span class="button btnProc01"><a href="../bbs/${ bbsMap.BBS_ID }_list.do">목록</a></span>
			</div>
   			<table cellspacing="0" cellpadding="0" border="0" class="tbl_type04">
				<colgroup>
					<col width="150px" />
					<col width="300px" />
					<col width="150px" />
					<col />
				</colgroup>
				<tbody>
					<tr>
						<th>제목</th>
						<td colspan="3"><c:if test="${ viewMap.ARTICLE_STEP > 0 }">[답글]</c:if><c:out value="${ viewMap.ARTICLE_TITLE }" /></td>
					</tr>
					<tr>
						<th>등록자</th>
						<td colspan="3"><c:out value="${ viewMap.ARTICLE_WRITER }" /></td>
					</tr>
					<tr>
						<th>등록일</th>
						<td><c:out value="${ viewMap.ARTICLE_WRITE_DATE }" /></td>
						<th>조회수</th>
						<td><c:out value="${ viewMap.ARTICLE_HIT }" /></td>
					</tr>
					<tr>
						<td colspan="4" id="view_contents">
							<div class="ac mb20">
								<c:forEach items="${fileListMap}" var="fileListMap">
								<c:if test="${fileListMap.FILE_TYPE eq 'jpg' or fileListMap.FILE_TYPE eq 'gif' or fileListMap.FILE_TYPE eq 'png'}">
								<img src="${host_name}${fileListMap.FILE_URLPATH}${fileListMap.FILE_RENAME}" class="border" style="width:449px; height:298px;" alt="이미지 설명" />
								</c:if>
								</c:forEach>
							</div>
							${ viewMap.ARTICLE_CONTENT }
						</td>
					</tr>
					<c:if test="${ bbsMap.BBS_FILE_COUNT ne '0'}">
					<tr>
						<th>첨부파일</th>
						<td colspan="3">
							<c:forEach items="${fileListMap}" var="fileListMap">
								<span class="button btnProc01">
									<input type="button" onclick="deleteFileBtn('${bbsMap.BBS_ID}', '${viewMap.ARTICLE_ID}', '${fileListMap.FILE_ID}')" value="삭제" />
								</span>
								&nbsp;&nbsp;
								<a href="/common/download.do?fileid=${fileListMap.FILE_ID}&jobid=${fileListMap.FILE_JOB_ID}">
									<c:out value="${fileListMap.FILE_NAME}" /><br />
								</a>
							</c:forEach>
						</td>
					</tr>
					</c:if>
				</tbody>
			</table>
			<c:if test="${ bbsMap.BBS_COMMENT_YN eq 'Y' }" >
			<c:import url="/bbs/comment.do">
				<c:param name="bbs_id" value="${bbsMap.BBS_ID}" />
				<c:param name="article_id" value="${viewMap.ARTICLE_ID}" />
			</c:import>
			<input type="hidden" name="returnURL" />
			</c:if>
			</form>
		</div>
	</div>
</body>
</html>